<%@ page language="java" contentType="text/html; charset=utf-8" %>
<%@ page import="java.util.*" %>
<%@ page import="java.net.*" %>
<%@ page import="java.lang.reflect.Method" %>
<%@ page import="java.io.File" %>
<%
//class列表
String classnames = request.getParameter("classnames") == null ? "":request.getParameter("classnames");
//类型列表
int type = getIntValue(request.getParameter("type"),-1);

String paramMaps = request.getParameter("paramMap") ==null?"":request.getParameter("paramMap");
List<String> classnameList = splitString2List(classnames,",");
List<Map> dataMapList = new ArrayList<Map>();
//将获取到的paramMap转换成MAP
List<String> paramMapStringList = splitString2List(paramMaps,";;");
for(int i=0;i < paramMapStringList.size(); i++){
    String paramMapString = paramMapStringList.get(i);
    List<String> paramMapTempString = splitString2List(paramMapString,"##");
    Map<String,String> paramMapTemp = new HashMap<String,String>();
    for(int j=0;j < paramMapTempString.size(); j++){
        if(paramMapTempString.get(j) != null && paramMapTempString.get(j).length() > 0){
            List<String> paramMapParm = splitString2List(paramMapTempString.get(j),"=");
            if(paramMapParm.size() == 2){
                paramMapTemp.put(paramMapParm.get(0),paramMapParm.get(1));
            }else if(paramMapParm.size() == 1){
                paramMapTemp.put(paramMapParm.get(0),"");
            }
        }
    }
    dataMapList.add(paramMapTemp);
}
for(int i=dataMapList.size();i < classnameList.size(); i++){
    HashMap dataMap = new HashMap();
    dataMapList.add(dataMap);
}
//获取绝对路径
String absPath=new java.io.File(application.getRealPath(request.getRequestURI())).getParent();
ClassLoader classLoader = new URLClassLoader(new URL[]{new File(absPath + "/classes").toURI().toURL()},Thread.currentThread().getContextClassLoader());  
Class clazz=classLoader.loadClass("checkmain.CheckExucute");//使用loadClass方法加载class,这个class是在urls参数指定的classpath下边。  

Method taskMethod = clazz.getMethod("execute",List.class,Integer.class,List.class);//反射
Object checkInstance = clazz.newInstance();
String returnstr = (String)taskMethod.invoke(checkInstance,classnameList,type,dataMapList);  

out.println(returnstr);

%>
<%!
private List<String> splitString2List(String input, String delim) {
    String[] inputArray = input.split(delim);
    ArrayList<String> list = new ArrayList<String>();
    for(String temp : inputArray){
        list.add(temp);
    }
    return list;
}
private int getIntValue(String v, int def) {
    try {
        return Integer.parseInt(v);
    } catch (Exception ex) {
        return def;
    }
}

%>
